package com.aracky.common.mapper;

import com.aracky.common.vo.DictVO;
import com.aracky.common.vo.UserVO;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
@DS("master")
public interface BaseMapper {
    /**
     * 找到字典信息
     * @param dictCodeList
     * @return
     */
    @Select(" <script>" +
            " SELECT sdd.dict_label name,sdd.dict_value value,sdt.dict_code code " +
            " FROM sys_dict_data sdd inner JOIN sys_dict_type  sdt on sdd.dict_id = sdt.dict_id " +
            " where sdd.status = 1 and sdt.status = 1  " +
            " AND sdt.dict_code IN " +
            "   <foreach " +
            "   collection='dictCodeList' index='index' item='item' open='(' separator=',' close=')'> " +
            "       #{item} " +
            "  </foreach>" +
            " </script>")
    List<DictVO> findDictList(@Param("dictCodeList") List<String> dictCodeList);

    /**
     * 查询用户信息
     * @param userIdList
     * @return
     */
    @Select("<script> " +
            " SELECT " +
            " su.user_id userId,su.user_name realName " +
            " FROM sys_user su " +
            " WHERE su.user_id IN " +
            "   <foreach " +
            "   collection='userIdList' index='index' item='item' open='(' separator=',' close=')'> " +
            "       #{item} " +
            "  </foreach>" +
            "</script>")
    List<UserVO> findUserList(@Param("userIdList") List<String> userIdList);

}
